const config = getApp().globalData.config
const T = getApp().globalData.T

// 职位大全（搜索）
function searchPosition(name, type){
  if (!name) return ;
  let token = getApp().globalData.token;
    return new Promise((resolve, reject) => {
      T.req({
        url: config.host + 'web/industry/positionlist',
        method: 'GET',
        data: {
          wd: name
        },
        success: (res) => {
            resolve(res)
        },
        fail: (err) => {
          reject(err);
        }
      })
    });
}

// 已发布的职位搜索
function searchPublishPosition(name, type) {
  if (!name) return;
  let token = getApp().globalData.token;
  return new Promise((resolve, reject) => {
    T.req({
      url: config.host + 'web/search/positionlist',
      method: 'GET',
      data: {
        wd: name,
        type:type
      },
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err);
      }
    })
  });
}

function searchCompany(name) {
  if (!name) return ;
  let token = getApp().globalData.token;
  return new Promise((resolve, reject) => {
    T.req({
      url: config.host + 'web/search/companylist',
      method: 'GET',
      data: {
        wd: name
      },
      success: (res) => {
        resolve(res)
      },
      fail: (err) => {
        reject(err);
      }
    })
  });
}

module.exports = {
  searchPosition,
  searchCompany,
  searchPublishPosition
}